package org.rvk.vms.dal.dao;

import java.util.List;

import javax.persistence.EntityManager;

import org.rvk.vms.dal.entities.Department;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * Implementation of the Department DAO.
 *
 * @author Ashish Kumar Sinha <aksinha.mail@gmail.com>
 */

public class DepartmentDaoImpl implements DepartmentDao {
	
	@Autowired
	private GenericDao genericDao;
	
	@Override
	public List<Department> getAllDepartments() {
		List<Department> departments = null;
		if(genericDao != null){
			EntityManager entityManager = genericDao.getEntityManager();
			if(entityManager != null){
				departments = (List<Department>) entityManager.createNamedQuery("Department.findAll").getResultList();
			}else {
				System.err.println(getClass().getName() + " :: Entity Manager is NULL");
			}
		}
		return departments;
	}
	
	

}
